package com.example.aigc_education.config;

import com.agentsflex.llm.spark.SparkLlm;
import com.agentsflex.llm.spark.SparkLlmConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * SparkLlm配置类
 */
@Configuration
public class SparkLlmConfiguration {

    @Value("${xf.config.app_id}")
    private String appId;

    @Value("${xf.config.api_secret}")
    private String apiSecret;

    @Value("${xf.config.api_key}")
    private String apiKey;

    @Value("${xf.config.version}")
    private String version;

    /**
     * SparkLlm配置
     * @return SparkLlmConfig
     */
    @Bean
    public SparkLlmConfig sparkLlmConfig() {
        SparkLlmConfig config = new SparkLlmConfig();
        config.setVersion(version);
        config.setAppId(appId);
        config.setApiSecret(apiSecret);
        config.setApiKey(apiKey);
        return config;
    }

    /**
     * SparkLlm
     * @param config SparkLlmConfig
     * @return SparkLlm
     */
    @Bean
    public SparkLlm sparkLlm(SparkLlmConfig config) {
        return new SparkLlm(config);
    }
}
